﻿using System.Linq;
using Microsoft.EntityFrameworkCore;
using YXChatApiService.Repository;

namespace YXChatApiService.Core.Common
{
    public abstract class DomainBaseManager<TEntity, TPrimaryKey>: IDomainBaseManager<TEntity,TPrimaryKey> where TEntity:class
    {
        private readonly IRepository<TEntity, TPrimaryKey> Repository;

        protected DomainBaseManager(IRepository<TEntity, TPrimaryKey> repository)
        {
            Repository = repository;
        }

        public Repository<TEntity, TPrimaryKey> Repo => (Repository<TEntity, TPrimaryKey>)Repository;
        public IQueryable<TEntity> Query => Repository.GetAll();
        public IQueryable<TEntity> QueryAsNoTracking => Query.AsNoTracking();
    }
}